# request进阶

# 模拟用户登录
# 获取cookie， 使用session进行请求
import requests

# 会话 使用会话请求可以保持cookies
session = requests.session()

# 登录
url = "https://passport.17k.com/ck/user/login"

headers = {
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36"
}

data = {
    "loginName": "19820385795",
    "password": "chenyanting123"
}

res = session.post(url, headers=headers, data=data)
# print(res.cookies)

bookRes = session.get("https://user.17k.com/ck/author/shelf?page=1&appKey=2406394919", )
print(bookRes.json())
res.close()
